package com.ezops.poc.validations;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;

import com.ezops.poc.validations.validators.IValidators;
import com.ezops.poc.validations.validators.MandatoryValidator;
import com.ezops.poc.validations.validators.RangeValidator;
import com.ezops.poc.validations.validators.TypeValidator;

/**
 * Test fixture class for providing test data.
 * 
 * @author vgaurav
 * 
 */
public class ValidationProcessTestFixture {

	private ValidationProcessTestFixture() {

	}

	public static List<LinkedList<IValidators>> getMandatoryValidatorForAccrualField() {
		List<LinkedList<IValidators>> allValidators = new ArrayList<LinkedList<IValidators>>();

		LinkedList<IValidators> validatords = new LinkedList<>();
		MandatoryValidator mandarotyValidator = new MandatoryValidator();
		mandarotyValidator.init("accrual", Arrays.asList(0, 1, 5), "Y");

		validatords.add(mandarotyValidator);

		allValidators.add(validatords);
		return allValidators;
	}

	public static List<LinkedList<IValidators>> getRangeValidatorFoProductCouponRateField() {
		List<LinkedList<IValidators>> allValidators = new ArrayList<LinkedList<IValidators>>();

		LinkedList<IValidators> validatords = new LinkedList<>();
		IValidators rangeValidator = new RangeValidator();
		rangeValidator.init("Product CouponRate", Arrays.asList(0, 1, 5),
				"0-100");

		validatords.add(rangeValidator);

		allValidators.add(validatords);
		return allValidators;

	}

	public static List<LinkedList<IValidators>> getMultipleValidatorsForSameField() {
		List<LinkedList<IValidators>> allValidators = new ArrayList<LinkedList<IValidators>>();

		LinkedList<IValidators> validatords = new LinkedList<>();
		IValidators mandatoryValidator = new MandatoryValidator();
		//Mandatory only for CDS
		mandatoryValidator.init("Product CouponRate", Arrays.asList(4), "Y");
		validatords.add(mandatoryValidator);
		
		allValidators.add(validatords);
		
		LinkedList<IValidators> nextValidatords = new LinkedList<>();
		//For BOND, not mandatory but has range check.
		IValidators nextMandatoryValidator = new MandatoryValidator();
		nextMandatoryValidator.init("Product CouponRate", Arrays.asList(1), "N");

		nextValidatords.add(nextMandatoryValidator);
		
		IValidators rangeValidator = new RangeValidator();
		rangeValidator.init("Product CouponRate", Arrays.asList(1),
				"0-100");
		nextValidatords.add(rangeValidator);

		allValidators.add(nextValidatords);

		return allValidators;

	}
	
	public static List<LinkedList<IValidators>> getMandatoryAndTypeValidatorForTickerSymbolField() {
		List<LinkedList<IValidators>> allValidators = new ArrayList<LinkedList<IValidators>>();

		
		LinkedList<IValidators> oneRowValidator = new LinkedList<>();
		IValidators mandatoryValidator = new MandatoryValidator();
		//Mandatory only for CDS
		mandatoryValidator.init("Product TickerSymbol", Arrays.asList(4), "Y");
		oneRowValidator.add(mandatoryValidator);
		
		IValidators typeValidator = new TypeValidator();
		typeValidator.init("Product TickerSymbol", Arrays.asList(4),
				"Alphanumeric");//(0-8 chars)

		oneRowValidator.add(typeValidator);

		allValidators.add(oneRowValidator);
		return allValidators;

	}
	
	public static List<LinkedList<IValidators>> getDecimalTypeValidatorForSettleAmoutField() {
		List<LinkedList<IValidators>> allValidators = new ArrayList<LinkedList<IValidators>>();

		
		LinkedList<IValidators> oneRowValidator = new LinkedList<>();
		IValidators mandatoryValidator = new MandatoryValidator();
		//Mandatory only for CDS
		mandatoryValidator.init("Settle Amount", Arrays.asList(4), "Y");
		oneRowValidator.add(mandatoryValidator);
		
		IValidators typeValidator = new TypeValidator();
		typeValidator.init("Settle Amount", Arrays.asList(4),
				"Decimal(*.2)");

		oneRowValidator.add(typeValidator);

		allValidators.add(oneRowValidator);
		return allValidators;

	}
	
	public static List<LinkedList<IValidators>> getFixedTypeValidatorForBuySellField() {
		List<LinkedList<IValidators>> allValidators = new ArrayList<LinkedList<IValidators>>();

		
		LinkedList<IValidators> oneRowValidator = new LinkedList<>();
		IValidators mandatoryValidator = new MandatoryValidator();
		//Mandatory only for CDS
		mandatoryValidator.init("Buy Sell", Arrays.asList(4), "Y");
		oneRowValidator.add(mandatoryValidator);
		
		IValidators typeValidator = new TypeValidator();
		typeValidator.init("Buy Sell", Arrays.asList(4),
				"Fixed(BUY,SELL)");

		oneRowValidator.add(typeValidator);

		allValidators.add(oneRowValidator);
		return allValidators;

	}
	
	public static List<LinkedList<IValidators>> getDateTypeValidatorForTradingDayField() {
		List<LinkedList<IValidators>> allValidators = new ArrayList<LinkedList<IValidators>>();

		
		LinkedList<IValidators> oneRowValidator = new LinkedList<>();
		IValidators mandatoryValidator = new MandatoryValidator();
		//Mandatory only for CDS
		mandatoryValidator.init("tradingDay", null, "Y");
		oneRowValidator.add(mandatoryValidator);
		
		IValidators typeValidator = new TypeValidator();
		typeValidator.init("tradingDay", Arrays.asList(4),
				"Date(MM/dd/yyyy)");

		oneRowValidator.add(typeValidator);

		allValidators.add(oneRowValidator);
		return allValidators;

	}

	public static List<LinkedList<IValidators>> getAlphaTypeValidatorForTickerSymbolField() {
		List<LinkedList<IValidators>> allValidators = new ArrayList<LinkedList<IValidators>>();

		
		LinkedList<IValidators> oneRowValidator = new LinkedList<>();
		IValidators typeValidator = new TypeValidator();
		//Mandatory only for CDS
		typeValidator.init("Product TickerSymbol", null, "Alphanumeric(<5 chars)");
		oneRowValidator.add(typeValidator);
		
		
		IValidators typeValidatorGreaterThan = new TypeValidator();
		typeValidatorGreaterThan.init("BookId", Arrays.asList(4),
				"Alphanumeric(>3)");

		oneRowValidator.add(typeValidatorGreaterThan);

		
		allValidators.add(oneRowValidator);
		return allValidators;

	}

}
